'''
状态信息追加
1.创建保存图的状态的字典  foo:Annotated[list[int],add]
2.创建智能体
3.创建带状态的图
4.添加节点 节点和智能体绑定
5.编译图
6.使用：通过图执行智能体和管理  invoke  _graph.invoke({"foo":[10]})
'''

from typing import TypedDict,Annotated
from langgraph.graph import START,END,StateGraph
from operator import add

class State(TypedDict):
    foo:Annotated[list[int],add]


def agent_01(state):
    return {'foo':[state['foo'][0] + 1]}

builder = StateGraph(State)
builder.add_node("node_01",agent_01)
builder.add_edge(START,"node_01")
builder.add_edge("node_01",END)
graph = builder.compile()

r = graph.invoke({'foo':[10]})
print(r)